using UnityEngine;
using System.Collections;

public class Stats : MonoBehaviour {
	
	public SpawnManager spawner;
    static public Player player;
	
	void Start () 
	{
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
	}
	
	void Update () 
	{
		if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
		{
            Touch touch = Input.touches[0];

            if (guiTexture.HitTest(touch.position))
            {
                hideGUI();
                player.whenChangeWave();
                spawner.run();
            }
		}
	}
	
	public void showGUI ()
	{
        Debug.Log("Apareci");
        gameObject.SetActive(true);
	}
	
	public void hideGUI ()
	{
        Debug.Log("HIDEI");
        gameObject.SetActive(false);
	}
	
	void OnMouseDown ()
	{
		hideGUI();
        player.whenChangeWave();
		spawner.run();
        Debug.Log("clicei");
	}

    public static void addStats(int stat, int value)
    {
		switch (stat)
        {
            case 1:
			player.cStats.strength += value;
			PlayerPrefs.SetInt("playerStrength", player.cStats.strength);
			Debug.Log("S/Str: " + player.cStats.strength);
			break;

            case 2:
			player.cStats.agility += value;
			PlayerPrefs.SetInt("playerAgility", player.cStats.agility);
			Debug.Log("S/Agi: " + player.cStats.agility);
			break;

            case 3:
            player.cStats.vitality += value;
			PlayerPrefs.SetInt("playerVitality", player.cStats.vitality);
			Debug.Log("S/Vit: " + player.cStats.vitality);
			break;
			
            case 4:
			player.cStats.energy += value;
			PlayerPrefs.SetInt("playerEnergy", player.cStats.energy);
			Debug.Log("S/Ene: " + player.cStats.energy);
			break;
        }
    }

    public int getMaxHP()
    {
        return 100 + (player.cStats.vitality * (200 / 99));
    }
}
